<?php

namespace addons\csmitsm\controller;

use addons\csmitsm\library\xcore\xcore\utils\XcIncludeFileUtils;
use think\Loader;
use Cron\CronExpression;
use think\addons\Controller;
use addons\csmitsm\library\xcore\xcore\utils\XcMessageNotifyUtils;

class Index extends Controller
{

    public function index()
    {
        $this->error("当前插件暂无前台页面");
    }


    // http://fastadmin_addons_csmitsm.fa.net/addons/csmitsm/index/test
    public function test()
    {

        if (!class_exists('\Cron\CronExpression')) {
            $path = XcIncludeFileUtils::getAddonsPath("/library/xcore/xcore/utils/lib/Cron");
            Loader::addNamespace('Cron',  $path);
        }

        $cron = CronExpression::factory("* 22 * * *");

        // 创建 CronExpression 对象
        $cron = CronExpression::factory('0 0 * * *'); // 每天午夜执行

        // 获取多次执行时间
        $currentDate = new \DateTime();

        for ($i = 0; $i < 3; $i++) {
            $nextRunDate = $cron->getNextRunDate($currentDate);
            $nextRunDates[] = $nextRunDate->format('Y-m-d H:i:s');
        }
        pp($nextRunDates);

        if ($cron->isDue()) {
            echo "true";
        } else {
            echo "false";
        }
    }
}
